class Exploitdb < Formula
  desc "Database of public exploits and corresponding vulnerable software"
  homepage "https://www.exploit-db.com/"
  url "https://github.com/offensive-security/exploitdb.git",
      tag:      "2022-09-24",
      revision: "c5397147d9e6ad8ebb47c3d99113be7b36e9c129"
  version "2022-09-24"
  license "GPL-2.0-or-later"
  head "https://github.com/offensive-security/exploitdb.git", branch: "master"

  bottle do
    sha256 cellar: :any_skip_relocation, arm64_monterey: "a589d1e158ef83334e5077149e0c05e65c66fa87da980075feba760f10cc955a"
    sha256 cellar: :any_skip_relocation, arm64_big_sur:  "bf37b4af3206479eb1b58eb943d0f681cb76038e8cb5301590ff3f6d20ecb7d4"
    sha256 cellar: :any_skip_relocation, monterey:       "7151c0184de5249adaa10423e20e2b0afd7ce6c0b424d0a9b6cc18d6dd744ac5"
    sha256 cellar: :any_skip_relocation, big_sur:        "02fe7e0aee3b70f9738fff8798908319ca4f78ff20ee4b596c42e467e4d2f703"
    sha256 cellar: :any_skip_relocation, catalina:       "00fe6f2969c6f7a18fb92fbaf98fd4beb093f5cca43a9ef060eebbf56b5c8374"
    sha256 cellar: :any_skip_relocation, x86_64_linux:   "77bebf69dfd7ab2198ad3ad437789949de2841acecd319f2737050de86668c91"
  end

  def install
    inreplace "searchsploit",
              "rc_file=\"\"", "rc_file=\"#{etc}/searchsploit_rc\""

    optpath = opt_share/"exploitdb"
    inreplace ".searchsploit_rc" do |s|
      s.gsub! "\"/opt/exploitdb\"", optpath
      s.gsub! "\"/opt/exploitdb-papers\"", "#{optpath}-papers"
    end

    bin.install "searchsploit"
    etc.install ".searchsploit_rc" => "searchsploit_rc"

    pkgshare.install %w[.git exploits files_exploits.csv files_shellcodes.csv
                        shellcodes]
  end

  test do
    system "#{bin}/searchsploit", "sendpage"
  end
end
